﻿@model IEnumerable<ArivisTests.Models.TestScenario>

@{
    ViewBag.Title = "Test Scenarios";
    int page = ViewBag.Page;
    int pageCount = ViewBag.PageCount;
    int pageSize = ViewBag.PageSize;
    int testCount = ViewBag.TestCount;
    int rowCount = page * pageSize + 1;
}

@section Navigation{
    @ViewBag.Title
}

@if (pageCount > 1)
{
    <table class="paging">
        <tr>
            <td>Show:</td>
            @for (int i = 0; i < pageCount; i++)
            {
                int from = i*pageSize + 1;
                int to = Math.Min((i + 1) * pageSize, testCount);
                string text = string.Format("{0}-{1}", from, to);
                if (i == page)
                {
                <td><strong>@text</strong></td>
                }
                else
                {
                <td>@Html.ActionLink(text, "Index", new { page = i })</td>
                }
            }
        </tr>
    </table>
}

<table class="index-table">
    <tr>
        <th style="width:1%;"></th>
        <th>
            @Html.DisplayNameFor(model => model.Name)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Owner)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Duration)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Url)
        </th>
        <th style="width:1%;"></th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td style="text-align:right">@(rowCount++)</td>
        <td style="white-space:nowrap">
            @Html.ActionLink(item.Name, "Details", new { id=item.Id })
        </td>
        <td style="white-space:nowrap">
            @Html.DisplayFor(modelItem => item.Owner.UserName)
        </td>
        <td style="white-space:nowrap">
            @Html.DisplayFor(modelItem => item.Duration)
        </td>
        <td style="white-space:nowrap">
            @Html.DisplayFor(modelItem => item.Url)
        </td>
        <td style="white-space:nowrap">
            @Html.ActionLink("Edit", "Edit", new { id=item.Id }) |
            @Html.ActionLink("Delete", "Delete", new { id=item.Id })
        </td>
    </tr>
}
</table>

<p>
    @Html.ActionLink("Create New", "Create")
</p>
